using System;
using System.Globalization;
using System.Runtime.InteropServices;
using System.Reflection;
using System.Data;
using System.Text;

using CdcSoftware.Pivotal.Engine;
using CdcSoftware.Pivotal.Engine.Types.Database;
using CdcSoftware.Pivotal.Engine.Types.DataTemplates;
using CdcSoftware.Pivotal.Engine.Types.Localization;
using CdcSoftware.Pivotal.Engine.Types.ServerTasks;

using CdcSoftware.Pivotal.Applications.Core.Server;
using CdcSoftware.Pivotal.Applications.Core.Server.InteractionServices;
using CdcSoftware.Pivotal.Applications.Core.Common;

namespace Pcm.Retail.Server.FormTasks
{
    /// <summary>
    /// The Form server task class to undertake some specfic business tasks for a business object
    /// associated with a specified form. It will call service server task to share business
    /// functionality that are not directly related to a form.
    /// </summary>
    /// <history>
    /// #Revision   Date            Author      Description
    /// 6.0.12.1    31-01-2013      DS          Initial version for Retail.
    /// </history>
    public class RE_AddOrderProductItem : AbstractDataTemplateServerTask
    {
        #region Private fields
        #endregion

        #region DataTemplateServerTask methods
       
        #endregion

        #region Public methods

        /// <summary>
        /// Method overridden to support the default setting of the default fields passed through transition point param.
        /// </summary>
        /// <param name="dataTemplate"></param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        /// <history>
        /// #Revision   Date            Author      Description
        /// 6.0.9.1     12-12-2011      DS          Initial version for Retail.
        /// </history>
        protected override DataSet NewData(DataTemplate dataTemplate, ParameterList parameters)
        {
            try
            {
                this.TransitionPointParameter.ParameterList = parameters;
                DataSet dataSet = this.SystemServer.DataService.NewDataDirect(dataTemplate, parameters);
                DataRow primaryDataRow = dataSet.Tables[dataTemplate.PrimaryDataSection.Name].Rows[0];
                this.TransitionPointParameter.SetDefaultColumns(primaryDataRow);
                this.TransitionPointParameter.CopyToParameterList(parameters);
                return dataSet;
            }
            catch (Exception ex)
            {
                throw new PivotalApplicationCoreException(ex.Message, ex);
            }
        }
        #endregion
    }
}
